package top.jiangqiang.qyblog.portal.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.jiangqiang.qyblog.common.base.controller.BaseController;
import top.jiangqiang.qyblog.common.base.query.PageResult;
import top.jiangqiang.qyblog.common.base.response.Result;
import top.jiangqiang.qyblog.common.constant.RequestURLConstants;
import top.jiangqiang.qyblog.core.domain.dto.NavQueryDto;
import top.jiangqiang.qyblog.core.domain.vo.NavVo;
import top.jiangqiang.qyblog.core.service.INavService;

/**
 * @author jiangqiang
 * @date 2022-11-27
 */
@RequiredArgsConstructor
@RestController
@RequestMapping(RequestURLConstants.PUBLIC_BLOG_NAV_CONTROLLER_PREFIX)
@Tag(name = "博客导航菜单接口")
public class PublicNavController extends BaseController {
    private final INavService navService;

    @GetMapping
    @Operation(summary = "根据条件查询博客菜单列表", description = "支持分页，排序等功能")
    public Result<PageResult<NavVo>> list(@ParameterObject @Validated NavQueryDto navQueryDto) {
        return navService.findByCondition(navQueryDto);
    }

    @GetMapping("/{id}")
    @Operation(summary = "查询菜单详情", description = "查询菜单详情")
    public Result<NavVo> get(@PathVariable Long id) {
        return navService.getNav(id);
    }

}
